import logging,time,os
BASE_PATH = os.path.dirname(os.path.dirname(__file__))
LOG_PATH = os.path.join(BASE_PATH,'logs')
if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)
nowtime = time.strftime("%Y-%m-%d %H:%M:%S")
class Logger():
    def __init__(self):
        self.logname = os.path.join(LOG_PATH,f'{time.strftime("%Y%m%d")}.log')
    def logger(self):
        logger = logging.getLogger('log')
        logger.setLevel(logging.DEBUG)
        formater = logging.Formatter(f'{nowtime}-%(filename)s-%(levelname)s:%(message)s')
        filelogger = logging.FileHandler(self.logname,mode='a',encoding='utf-8')
        console = logging.StreamHandler()
        console.setLevel(logging.DEBUG)
        filelogger.setLevel(logging.DEBUG)
        filelogger.setFormatter(formater)
        console.setFormatter(formater)
        logger.addHandler(filelogger)
        logger.addHandler(console)
        return logger



logger = Logger().logger()


